package io;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class FlushDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos =new FileOutputStream("bos.txt");
        BufferedOutputStream bos =new BufferedOutputStream(fos);
        String line ="你有没有看见城市正在分崩离析,你有没有听见孩子们的悲鸣";
        bos.write(line.getBytes(StandardCharsets.UTF_8));
        System.out.println("写出完毕");
        bos.flush(); //flush:冲水
        bos.close(); //缓冲流close()时会自动调用一次flush()确保所有数据关闭前写出

    }
}
